package com.lanren.demo;

import android.app.Application;

import com.lanren.easyhttp.EasyHttp;
import com.lanren.easyhttp.cache.converter.SerializableDiskConverter;

/**
 * @ClassName MyApplication
 * @Description TODO
 * @Author chongheng.wang
 * @Date 2019/11/30 22:44
 * @Version 1.0
 */
public class MyApplication extends Application {

    @Override
    public void onCreate() {
        super.onCreate();
        EasyHttp.init(this);
        EasyHttp.getInstance()
                .debug("LRHttp", true)
                .setReadTimeOut(60 * 1000)
                .setWriteTimeOut(60 * 1000)
                .setConnectTimeout(60 * 1000)
                .setRetryCount(3)//默认网络不好自动重试3次
                .setRetryDelay(500)//每次延时500ms重试
                .setRetryIncreaseDelay(500)//每次延时叠加500ms
                .setCacheDiskConverter(new SerializableDiskConverter())//默认缓存使用序列化转化
                .setCacheMaxSize(50 * 1024 * 1024)//设置缓存大小为50M
                .setCacheVersion(1);//缓存版本为1
//                .addInterceptor(new CustomSignInterceptor())
//                .setCertificates()//信任所有证书
//                .addCommonHeaders(getHttpHeaders());//设置全局公共头,不会动态更新头部数据，只能设置不变的信息
    }
}
